package com.example.tliaswebmanagement.controller;


import com.example.tliaswebmanagement.pojo.Result;
import com.example.tliaswebmanagement.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
//员工管理控制器
@RestController
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping
    public Result upload(MultipartFile image) throws Exception {
        log.info("上传文件名{}",image.getOriginalFilename());
        //调用阿里云oss工具类 进行文件上传
        String url = aliOSSUtils.upload(image);
        log.info("文件上传成功，文件访问url：{}",url);
        return Result.success(url);

    }
}
